package org.hfy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 外发状态枚举
 * 
 * @author hfy
 * @version 1.0
 */
@Getter
@AllArgsConstructor
public enum OutsourcingStatusEnum {
    
    OUTSOURCED("OUTSOURCED", "已外发"),
    PROCESSING("PROCESSING", "加工中"),
    RETURNED("RETURNED", "已回厂"),
    CANCELLED("CANCELLED", "已取消");
    
    private final String code;
    private final String description;
    
    /**
     * 根据代码获取枚举
     */
    public static OutsourcingStatusEnum fromCode(String code) {
        for (OutsourcingStatusEnum status : OutsourcingStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的外发状态代码: " + code);
    }
    
    /**
     * 根据描述获取枚举
     */
    public static OutsourcingStatusEnum fromDescription(String description) {
        for (OutsourcingStatusEnum status : OutsourcingStatusEnum.values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的外发状态描述: " + description);
    }
} 